package Panels;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.sql.ResultSet;

import javax.swing.JButton;
import javax.swing.JComboBox;

import Runables.Run_principal;

import componentes.ConexionBD;
import componentes.labtext;
import componentes.panelconfondo;

public class PanelGCafeteria extends panelconfondo implements ActionListener {
	GridBagConstraints gbc;
	JButton bcontinuar,breset;
	int panel;
	labtext cafeteria,idcine;
	JComboBox empleado;
	
	
public PanelGCafeteria(){
	super.setimagen("/recursos/cine1.jpg");
	panel = 1;
	cargaempleados();
	this.dibujar();
}


	

	public void actionPerformed(ActionEvent e) {
		
		
	}

public void dibujar(){
	this.setLayout(new GridBagLayout());
	cafeteria = new labtext(" Cafeteria : ",2,1,4);
	idcine = new labtext(" Cine : ",2,1,4);
    gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
			GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(
					5, 5, 5, 5), 0, 0);
	this.add(cafeteria,gbc);
	 gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
				GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(
						5, 5, 5, 5), 0, 0);
	this.add(idcine,gbc);

		 gbc = new GridBagConstraints(0, 2, 1, 1, 0, 0,
					GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(
							5, 5, 5, 5), 0, 0);
			this.add(empleado,gbc);
	
}
	
public void cargaempleados(){
	
	String consultaempleados = new String();
	
	if(Run_principal.user.getTipo().equals("Admin")){
		
		consultaempleados = "Select nombre from trabajador where tipo like \"Bar\"";
	}

	if(Run_principal.user.getTipo().equals("Director")){
		consultaempleados = "Select nombre from trabajador where tipo like \"Bar\" and idcine ="+ Run_principal.user.getIdcine();
	}
	
	empleado = new JComboBox();
	try {
		ResultSet rs = ConexionBD.executeQuery(consultaempleados);
	    
		while(rs.next()){
	    	empleado.addItem(rs.getString(1));
	    }
	}catch(Exception e){
		e.printStackTrace();
	}
}
	
}